package com.greate.community.util;

public class BusinessException extends RuntimeException{
    private String msg;

    private int code = 500;

    public BusinessException(String msg) {
        super(msg);
        this.msg = msg;
    }
    public BusinessException(String msg, int code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public BusinessException(BusCodeEnum busCodeEnum){
        super(busCodeEnum.getMsg());
        this.code = busCodeEnum.getCode();
        this.msg = busCodeEnum.getMsg();
    }

    public BusinessException(String msg, Throwable cause) {
        super(msg, cause);
        this.msg = msg;
    }

    public BusinessException(BusCodeEnum busCodeEnum, Throwable cause) {
        super(busCodeEnum.getMsg(), cause);
        this.code = busCodeEnum.getCode();
        this.msg = busCodeEnum.getMsg() + ":" + cause.getMessage();
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
